namespace QMVnSoft.Lists
{
    using QMVnSoft;
    using QMVnSoft.Controls;
    using QMVnSoft.DAL;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class FormDmTGTSEditor : FormListEditor
    {
        private IContainer components;
        private LabelControl lblLoai_TGTS;
        private LabelControl lblLoai_TGTS0;
        private LabelControl lblMa_TGTS;
        private LabelControl lblTen_TGTS;
        private LabelControl lblTen_TGTS_E;
        private TextOption txtLoai_TGTS;
        private TextControl txtMa_TGTS;
        private TextControl txtTen_TGTS;
        private TextControl txtTen_TGTS_E;

        public FormDmTGTSEditor()
        {
            this.InitializeComponent();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            //ComponentResourceManager manager = new ComponentResourceManager(typeof(FormDmTGTSEditor));
            this.txtMa_TGTS = new TextControl();
            this.lblMa_TGTS = new LabelControl();
            this.txtTen_TGTS = new TextControl();
            this.lblTen_TGTS = new LabelControl();
            this.txtTen_TGTS_E = new TextControl();
            this.lblTen_TGTS_E = new LabelControl();
            this.lblLoai_TGTS0 = new LabelControl();
            this.txtLoai_TGTS = new TextOption();
            this.lblLoai_TGTS = new LabelControl();
            base.SuspendLayout();
            base.txtMa_Loai3.FirstFilter = "Type = 'TG3'";
            base.txtMa_Loai3.Location = new Point(0x18c, 0x74);
            base.txtMa_Loai3.Size = new Size(0x85, 20);
            base.txtMa_Loai3.TabIndex = 6;
            base.txtMa_Loai2.FirstFilter = "Type = 'TG2'";
            base.txtMa_Loai2.Location = new Point(0x103, 0x74);
            base.txtMa_Loai2.Size = new Size(0x86, 20);
            base.txtMa_Loai2.TabIndex = 5;
            base.txtMa_Loai1.FirstFilter = "Type = 'TG1'";
            base.txtMa_Loai1.Location = new Point(0x7b, 0x74);
            base.txtMa_Loai1.Size = new Size(0x85, 20);
            base.txtMa_Loai1.TabIndex = 4;
            base.lblPhan_Loai.Location = new Point(12, 0x77);
            this.txtMa_TGTS.CharacterCasing = CharacterCasing.Upper;
            this.txtMa_TGTS.CheckTextSearched = false;
            this.txtMa_TGTS.DisabledForeColor = Color.Empty;
            this.txtMa_TGTS.Font = new Font("Arial", 8.25f);
            this.txtMa_TGTS.Location = new Point(0x7b, 0x1c);
            this.txtMa_TGTS.MaxLength = 0x20;
            this.txtMa_TGTS.Name = "txtMa_TGTS";
            this.txtMa_TGTS.OldValue = null;
            this.txtMa_TGTS.Size = new Size(0x85, 20);
            this.txtMa_TGTS.TabIndex = 0;
            this.txtMa_TGTS.UserTextLength = AppInstance.TextControlLength.ItemCode;
            this.txtMa_TGTS.UserTrimMode = AppInstance.TextControlTrimMode.All;
//            this.txtMa_TGTS.Value = null;//manager.GetObject("txtMa_TGTS.Value");
            this.lblMa_TGTS.AutoSize = true;
            this.lblMa_TGTS.Font = new Font("Arial", 8.25f);
            this.lblMa_TGTS.Location = new Point(12, 0x1f);
            this.lblMa_TGTS.Name = "lblMa_TGTS";
            this.lblMa_TGTS.Size = new Size(0x2f, 14);
            this.lblMa_TGTS.TabIndex = 4;
            this.lblMa_TGTS.Text = "Mã lý do";
            this.txtTen_TGTS.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txtTen_TGTS.CheckTextSearched = false;
            this.txtTen_TGTS.DisabledForeColor = Color.Empty;
            this.txtTen_TGTS.Font = new Font("Arial", 8.25f);
            this.txtTen_TGTS.Location = new Point(0x7b, 50);
            this.txtTen_TGTS.MaxLength = 128;
            this.txtTen_TGTS.Name = "txtTen_TGTS";
            this.txtTen_TGTS.OldValue = null;
            this.txtTen_TGTS.Size = new Size(0x196, 20);
            this.txtTen_TGTS.TabIndex = 1;
            this.txtTen_TGTS.UserTextLength = AppInstance.TextControlLength.ItemDescription;
            this.txtTen_TGTS.UserTrimMode = AppInstance.TextControlTrimMode.All;
//            this.txtTen_TGTS.Value = null;//manager.GetObject("txtTen_TGTS.Value");
            this.lblTen_TGTS.AutoSize = true;
            this.lblTen_TGTS.Font = new Font("Arial", 8.25f);
            this.lblTen_TGTS.Location = new Point(12, 0x35);
            this.lblTen_TGTS.Name = "lblTen_TGTS";
            this.lblTen_TGTS.Size = new Size(0x33, 14);
            this.lblTen_TGTS.TabIndex = 4;
            this.lblTen_TGTS.Text = "Tên lý do";
            this.txtTen_TGTS_E.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txtTen_TGTS_E.CheckTextSearched = false;
            this.txtTen_TGTS_E.DisabledForeColor = Color.Empty;
            this.txtTen_TGTS_E.Font = new Font("Arial", 8.25f);
            this.txtTen_TGTS_E.Location = new Point(0x7b, 0x48);
            this.txtTen_TGTS_E.MaxLength = 128;
            this.txtTen_TGTS_E.Name = "txtTen_TGTS_E";
            this.txtTen_TGTS_E.OldValue = null;
            this.txtTen_TGTS_E.Size = new Size(0x196, 20);
            this.txtTen_TGTS_E.TabIndex = 2;
            this.txtTen_TGTS_E.UserTextLength = AppInstance.TextControlLength.ItemDescription;
            this.txtTen_TGTS_E.UserTrimMode = AppInstance.TextControlTrimMode.All;
//            this.txtTen_TGTS_E.Value = null;//manager.GetObject("txtTen_TGTS_E.Value");
            this.lblTen_TGTS_E.AutoSize = true;
            this.lblTen_TGTS_E.Font = new Font("Arial", 8.25f);
            this.lblTen_TGTS_E.Location = new Point(12, 0x4b);
            this.lblTen_TGTS_E.Name = "lblTen_TGTS_E";
            this.lblTen_TGTS_E.Size = new Size(0x4a, 14);
            this.lblTen_TGTS_E.TabIndex = 4;
            this.lblTen_TGTS_E.Text = "Tên tiếng Anh";
            this.lblLoai_TGTS0.AutoSize = true;
            this.lblLoai_TGTS0.Font = new Font("Arial", 8.25f);
            this.lblLoai_TGTS0.ForeColor = Color.Blue;
            this.lblLoai_TGTS0.Location = new Point(0x98, 0x61);
            this.lblLoai_TGTS0.Name = "lblLoai_TGTS0";
            this.lblLoai_TGTS0.Size = new Size(0x53, 14);
            this.lblLoai_TGTS0.TabIndex = 0x26;
            this.lblLoai_TGTS0.Text = "T-Tăng, G-Giảm";
            this.txtLoai_TGTS.CharacterCasing = CharacterCasing.Upper;
            this.txtLoai_TGTS.CheckTextSearched = false;
            this.txtLoai_TGTS.DisabledForeColor = Color.Empty;
            this.txtLoai_TGTS.Font = new Font("Arial", 8.25f);
            this.txtLoai_TGTS.InputMask = "T,G";
            this.txtLoai_TGTS.Location = new Point(0x7b, 0x5e);
            this.txtLoai_TGTS.Name = "txtLoai_TGTS";
            this.txtLoai_TGTS.OldValue = null;
            this.txtLoai_TGTS.Size = new Size(0x17, 20);
            this.txtLoai_TGTS.TabIndex = 3;
            this.txtLoai_TGTS.Text = "T";
            this.txtLoai_TGTS.Value = "T";
            this.lblLoai_TGTS.AutoSize = true;
            this.lblLoai_TGTS.Font = new Font("Arial", 8.25f);
            this.lblLoai_TGTS.Location = new Point(12, 0x61);
            this.lblLoai_TGTS.Name = "lblLoai_TGTS";
            this.lblLoai_TGTS.Size = new Size(0x4f, 14);
            this.lblLoai_TGTS.TabIndex = 0x24;
            this.lblLoai_TGTS.Text = "Loại tăng, giảm";
            base.AddTitleText = "Thêm mới lý do tăng giảm";
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.ClientSize = new Size(0x222, 150);
            base.Controls.Add(this.lblLoai_TGTS0);
            base.Controls.Add(this.txtLoai_TGTS);
            base.Controls.Add(this.lblLoai_TGTS);
            base.Controls.Add(this.lblTen_TGTS_E);
            base.Controls.Add(this.lblTen_TGTS);
            base.Controls.Add(this.lblMa_TGTS);
            base.Controls.Add(this.txtTen_TGTS_E);
            base.Controls.Add(this.txtTen_TGTS);
            base.Controls.Add(this.txtMa_TGTS);
            base.EditTitleText = "Sửa lý do tăng giảm";
            base.FirstFreeCode = "TG1";
            base.Name = "FormDmTGTSEditor";
            base.SecondFreeCode = "TG2";
            this.Text = "Thêm mới lý do tăng giảm";
            base.ThirdFreeCode = "TG3";
            base.Controls.SetChildIndex(base.lblPhan_Loai, 0);
            base.Controls.SetChildIndex(base.txtMa_Loai1, 0);
            base.Controls.SetChildIndex(base.txtMa_Loai2, 0);
            base.Controls.SetChildIndex(base.txtMa_Loai3, 0);
            base.Controls.SetChildIndex(this.txtMa_TGTS, 0);
            base.Controls.SetChildIndex(this.txtTen_TGTS, 0);
            base.Controls.SetChildIndex(this.txtTen_TGTS_E, 0);
            base.Controls.SetChildIndex(this.lblMa_TGTS, 0);
            base.Controls.SetChildIndex(this.lblTen_TGTS, 0);
            base.Controls.SetChildIndex(this.lblTen_TGTS_E, 0);
            base.Controls.SetChildIndex(this.lblLoai_TGTS, 0);
            base.Controls.SetChildIndex(this.txtLoai_TGTS, 0);
            base.Controls.SetChildIndex(this.lblLoai_TGTS0, 0);
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        public override bool OnSave()
        {
            DataRow localCurrentRow;
            if (string.IsNullOrEmpty(this.txtMa_TGTS.Text))
            {
                MessageBox.Show("Chưa nhập mã lý do!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (string.IsNullOrEmpty(this.txtTen_TGTS.Text))
            {
                MessageBox.Show("Chưa nhập tên lý do!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (base.NewChecked)
            {
                localCurrentRow = base.LocalTable.NewRow();
            }
            else
            {
                localCurrentRow = base.LocalCurrentRow;
            }
            localCurrentRow["Ma_TGTS"] = this.txtMa_TGTS.Value;
            localCurrentRow["Ten_TGTS"] = this.txtTen_TGTS.Value;
            localCurrentRow["Ten_TGTS_E"] = this.txtTen_TGTS_E.Value;
            localCurrentRow["Loai_TGTS"] = this.txtLoai_TGTS.Value;
            localCurrentRow["Ma_Loai1"] = base.txtMa_Loai1.Value;
            localCurrentRow["Ma_Loai2"] = base.txtMa_Loai2.Value;
            localCurrentRow["Ma_Loai2"] = base.txtMa_Loai2.Value;
            DmTGTSDataAccess access = new DmTGTSDataAccess();
            if (base.ShowMessage(localCurrentRow, access.SaveRow(base.NewChecked, localCurrentRow)))
            {
                return false;
            }
            if (base.NewChecked)
            {
                base.LocalTable.Rows.Add(localCurrentRow);
            }
            base.LocalCurrentRow = localCurrentRow;
            base.LocalTable.AcceptChanges();
            this.txtMa_TGTS.Focus();
            return base.OnSave();
        }

        public override void OnShow()
        {
            this.txtMa_TGTS.Value = base.LocalCurrentRow["Ma_TGTS"];
            this.txtTen_TGTS.Value = base.LocalCurrentRow["Ten_TGTS"];
            this.txtTen_TGTS_E.Value = base.LocalCurrentRow["Ten_TGTS_E"];
            this.txtLoai_TGTS.Value = base.LocalCurrentRow["Loai_TGTS"];
            base.txtMa_Loai1.Value = base.LocalCurrentRow["Ma_Loai1"];
            base.txtMa_Loai2.Value = base.LocalCurrentRow["Ma_Loai2"];
            base.txtMa_Loai2.Value = base.LocalCurrentRow["Ma_Loai2"];
            base.OnShow();
        }
    }
}

